package com.example.ioc.controller;

import com.example.ioc.config.StudentConfig;
import jakarta.annotation.PostConstruct;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: Li_yizYa
 * Date: 2025/7/9
 * Time: 17:36
 */
@RequestMapping("/prop")
@RestController
public class PropertiesController {
    @Value("${my.key}")
    private String myKey;

    @Value("${my.key2}")
    private Integer myKey2;

    @Value("${my.key3}")
    private Boolean myKey3;

    @RequestMapping("/readValue")
    public String readValue() {
        return "从配置文件中读取配置信息: " + myKey;
    }


    @PostConstruct
    public void readValue2() {
        System.out.println("从配置文件中读取配置信息: " + myKey);
        System.out.println("从配置文件中读取配置信息: " + myKey2);
        System.out.println("从配置文件中读取配置信息: " + myKey3);
    }

}
